<?php
/**
 * 外部音乐数据资源
 *
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/13 0013
 * Time: 14:55
 */
namespace app\api\model\outer;

use app\common\helper\Obj2Array;
use think\Model;

class MusicModel extends Model{
    protected $table = 'album_music';
    protected $connection = 'applet_album_config';

    public static function getAll() {
        $model = new self();
        $list = $model->alias('m')
            ->field(['a.ctitle' => 'cate_name', 'a.id' => 'cate_id', 'm.title', 'm.singer', 'm.music' => 'refer_url'])
            ->join('album_mucate a', 'a.id = m.type', 'left')
            ->select();

        $data = [];
        foreach ($list as $key => $item) {
           $data[] = $item->getData();
        }

        return $data;
    }
}